<!DOCTYPE html>
<html lang="en">
<head>
    <title>部门考勤页面</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style type="text/css">
        .table-width-depart{
            width: 1180px;
        }
        .table-width-area{
            width: 1070px;
        }
        .title{
            font-size: 20px;
            text-align: center;
            margin-bottom: 10px;
        }
        .row {
            margin-right: -15px;
            margin-left: 0px;
        }
        .col-md-12{
            padding-left: 0;
        }
        .reginTd{
            max-width: 105px;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
            position: relative;
        }
        .div-td-content-more{
            position:absolute;
            height:auto;
            z-index:999;
            line-height:20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display:none;
        }
        .div-td-content-more i{
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left:50px;
            top:-12px;
        }
    </style>
</head>
<body>
<section v-cloak class="content" id="app" style="min-height:100vh">
    <div class="table-width-area title">{{departName}}{{time}}考勤</div>
    <div class="div-td-content-more"><i></i></div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-bordered text-center table-width-depart" v-if="isRegionDepart==1">
                <thead>
                <tr>
                    <th style="width: 80px;">岗位</th>
                    <th style="width: 200px;">区域</th>
                    <th style="width: 80px;">姓名</th>
                    <th style="width: 80px;">出勤</th>
                    <th style="width: 80px;">签到时间</th>
                    <th style="width: 300px;">签到地点/请假原因</th>
                    <th style="width: 80px;">签退时间</th>
                    <th style="width: 300px;">签退地点</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in list">
                    <td :rowspan="item.roleNamespan" :class="{hidden: item.roleNamedis}">{{item.roleName}}</td>
                    <td style="text-align: left" :rowspan="item.regionNamespan" :class="{hidden: item.regionNamedis}">{{item.regionName}}</td>
                    <td style="color:#169BD5;cursor: pointer" @click="signInDetail(item)">{{item.name}}</td>
                    <td>
                        <i v-if="item.signState=='0'">
                            <i class="fa fa-check" style="color:#349f2f;"></i>
                        </i>
                        <i v-else-if="item.signState==1">
                            请假
                        </i>
                        <i v-else-if="item.signState==2">
                            <i class="fa fa-close" style="color:red;"></i>
                        </i>
                    </td>
                    <td>
                        {{item.createTime}}
                    </td>
                    <td style="text-align: left;" class="reginTd">
                        <span v-if="item.signState=='0'">{{item.address}}</span>
                        <span v-else-if="item.signState==1">{{item.remark}}</span>
                    </td>
                    <td>{{item.signOutTime}}</td>
                    <td style="text-align: left;" class="reginTd">{{item.signOutAddress}}</td>
                </tr>
                </tbody>
            </table>
            <table class="table table-bordered text-center table-width-area" v-if="isRegionDepart==0">
            <thead>
            <tr>
                <th style="width: 80px;">部门</th>
                <th style="width: 90px;">岗位</th>
                <th style="width: 80px;">姓名</th>
                <th style="width: 80px;">出勤</th>
                <th style="width: 80px;">签到时间</th>
                <th style="width: 300px;">签到地点/请假原因</th>
                <th style="width: 80px;">签退时间</th>
                <th style="width: 300px;">签退地点</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item,i) in list">
                <td :rowspan="item.departNamespan" :class="{hidden: item.departNamedis}">{{item.departName}}</td>
                <td :rowspan="item.roleNamespan" :class="{hidden: item.roleNamedis}">{{item.roleName}}</td>
                <td style="color:#169BD5;cursor: pointer" @click="signInDetail(item)">{{item.name}}</td>
                <td>
                    <i v-if="item.signState=='0'">
                        <i class="fa fa-check" style="color:#349f2f;"></i>
                    </i>
                    <i v-else-if="item.signState==1">
                        请假
                    </i>
                    <i v-else-if="item.signState==2">
                        <i class="fa fa-close" style="color:red;"></i>
                    </i>
                </td>
                <td>
                    {{item.createTime}}
                </td>
                <td style="text-align: left;" class="reginTd">
                    <span v-if="item.signState=='0'">{{item.address}}</span>
                    <span v-else-if="item.signState==1">{{item.remark}}</span>
                </td>
                <td>{{item.signOutTime}}</td>
                <td style="text-align: left;" class="reginTd">{{item.signOutAddress}}</td>
            </tr>
            </tbody>
        </table>
        </div>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click",".reginTd",function(e) {
            var text =$(this).text();
            if($('.div-td-content-more').is(':hidden')){
                if(text != "") {
                    text="<i></i>"+text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }}else{
                $('.div-td-content-more').hide();
            }
        });
        $("body").on("click",".div-td-content-more",function (e) {
            e.stopPropagation();
        });
        $("body").on("click",function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            list: [],
            months: [],
            userId: getCurrentUser().id,
            time: "",
            departId: "",
            departName: "",
            isRegionDepart: "",
            isToday: "",
            flag: "0"
        },
        methods: {
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            getMonths: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");
                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.months.push(that.insert_flg(dateTime, "-", "4"))
                }
            },
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    console.log(tmp)
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                return newstr;
            },
            getList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.signIn.getSignInDepartDetail, {
                    "departId": that.departId,
                    "isRegionDepart": that.isRegionDepart
                }, function (data) {
                    that.list = that.tablesMergeCell(data);
                }, true);
            },
            signInDetail: function (item) {
                var that = this;
                url = "/reportForm/signIn/detail.html?flag=1&userId=" + item.userId + "&time=" + that.time + "&userName=" + item.name;
                top.closeTabByPageId("signIn-detail");
                top.addTabs({id: "signIn-detail", title: item.name, close: true, url: url});
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            }
        },
        mounted: function () {
            //获取前5个月
            this.getMonths();
            var that = this;
            that.departId = $.wyui.page.urlParams.departId;
            that.departName = $.wyui.page.urlParams.departName;
            that.isRegionDepart = that.departName.indexOf("大区")>0 ? "1" : "0";
            that.time = new Date().Format("yyyy-MM-dd");
            that.getList();
        }

    });
</script>

</body>
</html>